export default {
  state: {
    isDark: localStorage.getItem("isDark") === "true" || false,
  },
  mutations: {
    SET_DARK_MODE(state, isDark) {
      state.isDark = isDark;
      localStorage.setItem("isDark", isDark);
    },
    CLEAR_DARK_MODE(state) {
      state.isDark = false;
      localStorage.removeItem("isDark");
    },
  },
  actions: {
    setDarkMode({ commit }, isDark) {
      // console.log("setDarkMode: ", typeof isDark);
      commit("SET_DARK_MODE", isDark);
    },
    clearDarkMode({ commit }) {
      commit("CLEAR_DARK_MODE");
    },
  },
  getters: {
    isDark: (state) => state.isDark,
  },
};
